#include "PDFManager.h"

PDFManager::PDFManager() : m_document(nullptr) {}

PDFManager::~PDFManager()
{
    if (m_document)
    {
        delete m_document;
    }
}

Poppler::Document* PDFManager::loadPdfFile(const QString &filename)
{
    if (m_document)
    {
        delete m_document;
    }

    m_document = Poppler::Document::load(filename);

    if (!m_document || m_document->isLocked())
    {
        delete m_document;
        m_document = nullptr;
    }

    return m_document;
}
